#include "Rasterizer.h"



Rasterizer::Rasterizer(Graphics& gfx, bool isWireFrame,bool twoSided)
	:
	twoSided(twoSided)
{
	D3D11_RASTERIZER_DESC rasterDesc = CD3D11_RASTERIZER_DESC(CD3D11_DEFAULT{});
	rasterDesc.FillMode = isWireFrame ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID;
	rasterDesc.CullMode = twoSided ? D3D11_CULL_NONE : D3D11_CULL_BACK;
	HR(GetDevice(gfx)->CreateRasterizerState(&rasterDesc, &pRasterizer));
}

void Rasterizer::Bind(Graphics& gfx)
{
	GetContext(gfx)->RSSetState(pRasterizer.Get());
}

std::shared_ptr<Rasterizer> Rasterizer::Create(Graphics& gfx, bool isWireFrame, bool twoSided)
{
	return std::make_shared<Rasterizer>(gfx,isWireFrame ,twoSided);
}
